/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.doc.sender.ui;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Insets;
import java.awt.Toolkit;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;

/**
 *
 * @author parent
 */
public class WaitingDialog extends JFrame {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                WaitingDialog test = new WaitingDialog();
                test.setAlwaysOnTop(true);
                test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                
                test.setVisible(true);
            }
        });
    }

    public WaitingDialog() {
        super();
        try {
           
            JLabel label = new JLabel();
            //ImageIcon imageIcon = new ImageIcon(ImageIO.read(getClass().getResourceAsStream("gfx/gear.gif")));
            ImageIcon imageIcon = new ImageIcon(getClass().getResource("gfx/gear.gif"));
            label.setIcon(imageIcon);
            imageIcon.setImageObserver(label);
            add(label);
            Toolkit kit = this.getToolkit();
            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice[] gs = ge.getScreenDevices();
            Insets in = kit.getScreenInsets(gs[0].getDefaultConfiguration());
 
            Dimension d = kit.getScreenSize();
            int max_width = (d.width - in.left - in.right);
            int max_height = (d.height - in.top - in.bottom);
            this.setSize(Math.min(max_width, 850), Math.min(max_height, 550));//whatever size you want but smaller the insets
            this.setLocation((int) (max_width - this.getWidth()) / 2, (int) (max_height - this.getHeight() ) / 2);
               
                //main gui is this app ... 
                
            pack();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
